import React, { Component } from 'react';
import {
  View,Text,StyleSheet,ScrollView,Image
} from 'react-native';
import * as DATA from '../data/data';
import pxToDp from '../common/comm';

export default class Zizhi extends Component {
  // 构造
    constructor(props) {
      super(props);
      // 初始状态
      this.state = {
        url:DATA.res+this.props.navigation.state.params.url,
        width:0,
        height:0
      };
    }

  componentDidMount() {
    Image.getSize(this.state.url,(width, height)=>{
      this.setState({width,height});
    })
  }
  render() {
    return (
    <ScrollView>
      <Image
          source={{uri:this.state.url}}
          style={{
            width:pxToDp(this.state.width),
            height:pxToDp(this.state.height)
          }}
      />
    </ScrollView>
    );
  }
}
